<?php

/**

 * 工作流程查询
 * 
 * @access  public 
 * @author  zhangyingheng<zhang_yh@jsumt.com.cn> 
 */

namespace Index\Controller;

use Think\Controller;

class SearchController extends BaseController {

    public function _initialize() {
        parent::_initialize();
    }

    public function index() {
        $this->title = '流程审批';
        $this->display();
    }

    public function search() {
        $data = I('get.');
        $where = '';
        if ($data['range'] == 1) {
            $where .= " and d.BEGIN_USER= '" . session('user_id') . "'";
        } else {
            $where .= " and c.USER_ID != '" . session('user_id') . "'";
        }

        if ($data['start'] && $data['end']) {
            $where .= " and c.CREATE_TIME between '" . $data['start'] . "' and '" . $data['end'] . "'";
        }
        $limit = $this->limit;
        $runs = $this->getLists(0, $limit, 0, $where);
        //    print_r($runs);
        $this->runs = $runs;
        $this->range = $data['range'];
        $this->start = $data['start'];
        $this->end = $data['end'];

        $this->title = '流程审批';
        $this->display();
    }

    public function dropload() {
        $where = '';
        if (I('range') == 1) {
            $where .= " and d.BEGIN_USER= '" . session('user_id') . "'";
        } else {
            $where .= " and c.USER_ID != '" . session('user_id') . "'";
        }

        if (I('start') && I('end')) {
            $where .= " and c.CREATE_TIME between '" . I('start') . "' and '" . I('end') . "'";
        }
        $limit = $this->limit;
        $runs = $this->getLists(0, $limit, 0, $where);
        //print_r($runs);die;
        foreach ($runs as $key => $row) {
            $runs[$key]['begin_user'] = getChineseName($row['begin_user']);
            $runs[$key]['user'] = getChineseName($row['user']);
        }
        $this->ajaxReturn($runs);
    }

}
